package cn.mooncode.basketballManage.service.impl;

import cn.mooncode.basketballManage.service.ICoachActiveService;
import cn.mooncode.basketballManage.mapper.CoachActiveMapper;
import cn.mooncode.basketballManage.pojo.CoachActive;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

/**
 * <p>
 * 服务实现类
 * </p>
 *
 * @author jwz
 * @since 2021-03-28
 */
@Service
public class CoachActiveServiceImpl extends ServiceImpl<CoachActiveMapper, CoachActive> implements ICoachActiveService {

    @Autowired
    private CoachActiveMapper coachActiveMapper;

    /**
     * 添加教练选择场地的点击数
     *
     * @param cid
     * @param sid
     * @return
     */
    @Override
    public boolean addHits(Integer cid, Integer sid) {
        CoachActive coachActive = coachActiveMapper.selectOne(new QueryWrapper<CoachActive>().eq("cid", cid).eq("sid", sid));
        if (null == coachActive) {
            return coachActiveMapper.addCoachActive(cid, sid);
        } else {
            return coachActiveMapper.updateCoachActive(cid, sid);
        }
    }
}
